package com.ruoyi.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.ruoyi.system.domain.ZcVehicle;
import com.ruoyi.system.mapper.ZcVehicleMapper;
import com.ruoyi.system.service.IZcVehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ZcVehicleServiceImpl implements IZcVehicleService {

    @Autowired
    private ZcVehicleMapper mapper;

    @Override
    public List<ZcVehicle> getOverWeightList(String checkDate) {
        ZcVehicle zcVehicle = new ZcVehicle();
        zcVehicle.setCheckDate(checkDate);
        zcVehicle.setTableName("zc_vehicle_" + this.yyyyMM(checkDate));
        return mapper.getOverWeightList(zcVehicle);
    }

    private String yyyyMM(String checkDate) {
        String yyyyMM = StrUtil.replace(checkDate, "-", "");
        yyyyMM = StrUtil.subPre(yyyyMM, 6);
        return yyyyMM;
    }
}
